package com.gxa.controller.gouhuocontroller;

import com.gxa.common.R;
import com.gxa.pojo.*;
import com.gxa.service.gouhuoservice.*;
import io.swagger.annotations.*;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

/**
 * @Author x
 */

@RestController
@RequestMapping("/GouHuoTuiHuoDan")
@Api(value = "退货单" , tags = "退货数据接口API")

@RequiresPermissions("购货退货单")
public class GouHuoTuiHuoDanController {

    @Autowired(required = false)
    public R r;

    @Autowired(required = false)
    GongYingShang46Service gouHuoService;

    @Autowired(required = false)
    private ShangPin46Service ShangPinService;

    @Autowired(required = false)
    private com.gxa.service.gouhuoservice.CangKu46Service CangKu46Service;

    @Autowired(required = false)
    GouHuoTuiHuoDan46Service gouHuoTuiHuo1Service;


    @ApiResponses({
            @ApiResponse(code = 200,message = "请求成功"),
            @ApiResponse(code = 400, message = "参数格式不对"),
            @ApiResponse(code = 404,message = "找不到页面"),
            @ApiResponse(code = 500,message = "后台服务错误")
    })


    @RequestMapping(value = "/selectAllGongYinShangForPage",method = RequestMethod.GET)
    @ApiOperation(value = "供应商退货查询接口" ,notes = "提供当前页码数与每页显示条数",httpMethod = "get",response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page",value = "当前页码数",required = true,dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "size",value = "每页显示条数", required = true,dataType = "int",paramType = "query")
    })
    public R selectAllGongYinShangForPage(int page,int size) {

//        r.setCode(200);
//        r.setMsg("查询成功！");
//        r.setCode(200);
//        r.setMsg("查询成功");
//        ArrayList<Object> list = new ArrayList<>();
//        list.add("jjj");
//        r.setData(list);

        return  gouHuoService.selectAllGongYingShangForPage(page,size);
    }

    @RequestMapping(value = "/selectAllGongYinShang", method = RequestMethod.GET)
    @ApiOperation(value = "供应商条件查询接口", notes = "提供当前页码数与每页显示条数", httpMethod = "get", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage", value = "当前页码数", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "每页显示条数", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "gongYingShangTypeId", value = "供应商类别", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "gongYingShangNumber", value = "供应商编号", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "gongYingShangMingCheng", value = "供应商名称", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "lianXiRen", value = "联系人", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "phone", value = "手机", required = false, dataType = "String", paramType = "query"),
    })
    public R selectAllGongYinShang(int currentPage,int pageSize, String gongYingShangTypeld, String gongYingShangNumber,
                                   String gongYingShangMingCheng, String lianXiRen, String phone) {
//        r.setCode(200);
//        r.setMsg("success");
//        ArrayList<Object> list = new ArrayList<>();
//        GongYingShang gongYingShang = new GongYingShang();
//        gongYingShang.setGongYingShangTypeId(55);
//        gongYingShang.setGongYingShangNumber("33");
//        gongYingShang.setGongYingShangMingCheng("国信安");
//        gongYingShang.setLianXiRen("gxa");
//        gongYingShang.setPhone("shouji");
//        list.add(gongYingShang);
//        r.setData(list);
//        return r;
        return  gouHuoService.selectAllGongYinShang( currentPage , pageSize, gongYingShangTypeld, gongYingShangNumber,
                gongYingShangMingCheng , lianXiRen, phone);
    }

    @RequestMapping(value = "/selectAllShangPinForPage", method = RequestMethod.GET)
    @ApiOperation(value = "商品扫描查询接口", notes = "提供当前页码数与每页显示条数", httpMethod = "get", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage", value = "当前页码数", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "pagesize", value = "每页显示条数", required = true, dataType = "int", paramType = "query")
    })
    public R selectAllShangPinForPage(int currentPage, int pageSize)
    {
//        r.setCode(200);
//        r.setMsg("success");
//        ArrayList<Object> list = new ArrayList<>();
//        list.add("kkk");
//        r.setData(list);
//        return r;
        return  ShangPinService.selectAllShangPinForPage(currentPage, pageSize);
    }

    @RequestMapping(value = "/selectAllShangPin", method = RequestMethod.GET)
    @ApiOperation(value = "商品查询接口", notes = "提供当前页码数与每页显示条数", httpMethod = "get", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage", value = "当前页码数", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "每页显示条数", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "shangPinBianHao", value = "商品编号", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "shangPinMingCheng", value = "商品名称", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "guiGeXingHao", value = "规格型号", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "unitName", value = "单位名称", required = false, dataType = "String", paramType = "query")
    })
    public R selectAllShangPin(int currentPage,int pageSize, String shangPinBianHao, String shangPinMingCheng, String guiGeXinHao,String unitName) {
//        r.setCode(200);
//        r.setMsg("success");
//        ArrayList<Object> list = new ArrayList<>();
//        ShangPin shangPin = new ShangPin();
//        shangPin.setShangPinBianHao("66");
//        shangPin.setShangPinMingCheng("68");
//        shangPin.setGuiGeXingHao("168");
//        list.add(shangPin);
//        r.setData(list);
//        return r;
        return  ShangPinService.selectAllShangPin(currentPage,pageSize,shangPinBianHao,shangPinMingCheng,guiGeXinHao,unitName);
    }

    @RequestMapping(value = "/selectbyCangKu", method = RequestMethod.GET)
    @ApiOperation(value = "仓库名称查询接口", notes = "提供当前页码数与每页显示条数", httpMethod = "get", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cangKuName", value = "显示仓库名称录入", required = true, dataType = "String", paramType = "query")
    })
    public R selectbyCangKu(String cangKuName) {
//        r.setCode(200);
//        r.setMsg("success");
//        ArrayList<Object> list = new ArrayList<>();
//        CangKu cangKu = new CangKu();
//        cangKu.setCangKuName("688");
//        list.add(cangKu);
//        r.setData(list);
//        return r;
        return  CangKu46Service.selectbyCangKu(cangKuName);
    }

//    @RequestMapping(value = "/insertGouHuoDanTui",method = RequestMethod.POST)
//    @ApiOperation(value = "保存并新增退货" ,notes = "提供当前页码数与每页显示条数",httpMethod = "post",response = R.class)
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "shuLiang",value = "数量",required = false,dataType = "String",paramType = "query"),
//            @ApiImplicitParam(name = "gouHuoDanJia",value = "购货单价", required = false,dataType = "String",paramType = "query"),
//            @ApiImplicitParam(name = "zheKouLv",value = "折扣率", required = false,dataType = "String",paramType = "query"),
//            @ApiImplicitParam(name = "gouHuoJinE",value = "购货金额", required = false,dataType = "String",paramType = "query"),
//            @ApiImplicitParam(name = "beiZhu",value = "备注", required = false,dataType = "String",paramType = "query"),
//            @ApiImplicitParam(name = "shangPin",value = "商品", required = true,dataType = "String",paramType = "query"),
//            @ApiImplicitParam(name = "cangKu",value = "仓库", required = true,dataType = "String",paramType = "query")
//    })
//    public R insertGouHuoDanTui(String shuLiang,String gouHuoDanJia,String ZheKouLv,String gouHuoJinE,String beiZhu,String shangPin,String cangKu)
//    {
//        r.setCode(200);
//        r.setMsg("success");
//        ArrayList<Object> list = new ArrayList<>();
//        CangKu cangKu1 = new CangKu();
//        cangKu1.setCangKuName("6888");
//        list.add(cangKu1);
//        ShangPin shangPin1 = new ShangPin();
//        shangPin1.setGuiGeXingHao("16888");
//        list.add(shangPin1);
//        r.setData(list);
//        return r;
    @RequestMapping(value = "/insertGouHuoTuiHuoDan", method = RequestMethod.POST)
    @ApiOperation(value = "保存并新增", notes = "提供当前页码数与每页显示条数", httpMethod = "post", response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
        public R insertGouHuoTuiHuoDan(@RequestBody GouHuoTuiHuo gouHuoTuiHuo)
        {

            return gouHuoTuiHuo1Service.insertGouHuoTuiHuoDan(gouHuoTuiHuo);
        }


//    @RequestMapping(value = "/selectByGouHuoDanTui",method = RequestMethod.GET)
//    @ApiOperation(value = "审核退货购货单" ,notes = "提供当前页码数与每页显示条数",httpMethod = "get",response = R.class)
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "shuLiang",value = "数量",required = false,dataType = "String",paramType = "query"),
//            @ApiImplicitParam(name = "gouHuoDanJia",value = "购货单价", required = false,dataType = "String",paramType = "query"),
//            @ApiImplicitParam(name = "zheKouLv",value = "折扣率", required = false,dataType = "String",paramType = "query"),
//            @ApiImplicitParam(name = "zheKouE",value = "折扣额", required = false,dataType = "String",paramType = "query"),
//            @ApiImplicitParam(name = "gouHuoJinE",value = "购货金额", required = false,dataType = "String",paramType = "query"),
//            @ApiImplicitParam(name = "beiZhu",value = "备注", required = false,dataType = "String",paramType = "query"),
//            @ApiImplicitParam(name = "shangPin",value = "商品", required = true,dataType = "String",paramType = "query"),
//            @ApiImplicitParam(name = "cangKu",value = "仓库", required = true,dataType = "String",paramType = "query")
//    })
//    public R selectbyGouHuoDanTui(String shuLiang,String guoHuoDanJia,String zheKouLv,String zheKouE,String gouHuoJinE,
//                                  String beiZhu,String shangPin,String cangKu) {
////        r.setCode(200);
////        r.setMsg("success");
////        ArrayList<Object> list = new ArrayList<>();
////        CangKu cangKu2 = new CangKu();
////        cangKu2.setCangKuName("6888");
////        list.add(cangKu2);
////        ShangPin shangPin2 = new ShangPin();
////        shangPin2.setGuiGeXingHao("16888");
////        list.add(shangPin2);
////        r.setData(list);
////        return r;
//    }

    @RequestMapping(value = "/ShenHeGouHuoTuiHuoDan", method = RequestMethod.POST)
    @ApiOperation(value = "审核购货退货单", notes = "提供当前页码数与每页显示条数", httpMethod = "post", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "shenHeZhuangTai", value = "审核状态", required = true, dataType = "int", paramType = "query")

    })
    public R ShenHeGouHuoTuiHuoDan(@RequestParam int shenHeZhuangTai) {
        return  gouHuoTuiHuo1Service.ShenHeGouHuoTuiHuoDan(shenHeZhuangTai);
    }
}

